<template>
	<view class="container">
		<view class="card" v-if="isshow" @tap="goUrl" v-for="(item,index) in listdata" :data-url="item.url">
			<view class="title">{{item.title}}</view>
			<view class="right-box">
				<view class="text">点击进入</view>
				<view class="right-iocn">
					<image src="../../../static/images/right_icon.png" mode="" class="right-img"></image>
				</view>
			</view>
		</view>
		<view class="showhide" v-if="!isshow">
			<image src="../../../static/images/no_data.png" mode="" class="show-img"></image>
			<view class="">暂无任务列表</view>
		</view>
	</view>
</template>

<script>
	var common = require('../../../utils/common.js');
	var app = getApp();
	var _this;
	const getworkList = () => {
		common.post('HouseApi&a=house_worker', {
			village_id:_this.village_id,
		}, data => {
			console.log('++++', data)
			if(data.menus_list.length > 0){
				_this.listdata = data.menus_list;
				_this.isshow = true;
			}else{
				_this.isshow = false;
			}
			
		});
	};
	export default {
		data() {
			return {
				listdata: {},
				numlist: {},
				village_id: 0,
				pigcms_id: 0,
				actcolor: '',
				btn_style: '',
				isshow: false,
			}
		},
		onShow() {
			// #ifdef H5
			common.hideWxShare()
			// #endif
		},
		onLoad(options) {
			_this = this;
			_this.village_id = options.village_id;
			// #ifdef H5
			console.log('准备跳小程序页', _this.id);
			common.webToMiniapp(_this.route, options, 'redirect')
			// #endif

			common.setMainColor(_this, function(config) {
				_this.actcolor = config.config.mobile_head_color
				_this.btn_style = 'background-color: ' + _this.actcolor + ';box-shadow:0px 30rpx 30rpx -30rpx ' + _this.actcolor +
					';';

				const res = uni.getStorageSync('village_key');
				if (res) {
					_this.village_id = res.village_id;
					_this.pigcms_id = res.pigcms_id;
					_this.village_name = res.village_name;
				};
				if (options.village_id && options.village_id != _this.village_id) {
					common.post('HouseApi&a=search_village', {
						village_id: options.village_id
					}, data => {
						_this.village_logo = data.village_logo ? data.village_logo : data.wechat_share_img;
						_this.village_id = options.village_id;
						_this.village_name = options.village_name;
						var res = {
							village_id: _this.village_id,
							village_name: _this.village_name,
							village_logo: _this.village_logo
						};
						if (options.pigcms_id) {
							res.pigcms_id = options.pigcms_id;
							_this.pigcms_id = options.pigcms_id;
						}
						uni.setStorageSync('village_key', res);
						getworkList()
					});
					return false;
				}
				console.log("oooooo",_this.village_id)
				getworkList()
			});
		},
		methods: {
			goUrl: function(e) {
				console.log('----------------------');
				console.log(e);
			
				if (e.type == 'submit') {
					common.upFormid(e);
				}
			
				if (e.currentTarget.dataset.goodsid) {
					goodsReport(e.currentTarget.dataset.goodsid);
				}
			
				var nums = e.currentTarget.dataset.nums;
				var pageTitle = e.currentTarget.dataset.url_title;
				var url = e.currentTarget.dataset.url;
			    
				if(url == ''){
					return;
				}
			    if (_this.village_id) {
			        url = common.changeURLArg(url, 'village_id', _this.village_id);
			    }
				
				if (_this.pigcms_id) {
					url = common.changeURLArg(url, 'pigcms_id', _this.pigcms_id);
				}
			
				if (!pageTitle) {
					pageTitle = '';
				}
				console.log('nums', nums)
				console.log('url_0', url)
				if (nums) {
					common.post('Login&a=house_adver_click', {
						adver_id: nums
					}, function(e) {
						common.parseUrl(url, '', false, pageTitle);
					});
				} else {
					common.parseUrl(url, '', false, pageTitle);
				}
			},
			gometerReading(){
				uni.navigateTo({
					url:'/pages/village/mobileMeterReading/selectApartment?village_id=' + _this.village_id
				})
			},
		},
		components: {

		}
	}
</script>

<style>
	page {
		background: #FFFFFF;
	}
	.container {
		margin: 0;
		padding: 0;
		height: 100%;
	}
	.card {
		background: rgb(245,245,245);
		margin: 30rpx;
		padding: 20rpx;
		border-radius: 20rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
	}
	.right-box {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
	}
	.text {
		font-size: 24rpx;
		font-weight: normal;
		font-stretch: normal;
		line-height: 90rpx;
		letter-spacing: 0px;
		color: #CCCCCC;
		margin-right: 10rpx;
	}
	.right-iocn {
		width: 30rpx;
		height: 30rpx;
	}
	.right-img {
		width: 100%;
		height: 100%;
		display: block;
	}
	.showhide {
		display: flex;
		height: 100%;
		justify-content: center;
		flex-direction: column;
		align-items: center;
	}
	.show-img {
		width: 374rpx;
		height: 288rpx;
		display: inline-block;
	}
</style>
